#ifndef __EI_MAI_SMART_MBGS_H__
#define __EI_MAI_SMART_MBGS_H__

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

//#if 0
//typedef struct eiMADP_SMART_MD_RESULT_S {
//	/* x0,y0,x1,y1 */
//	EI_S32 u32Rect[4];
//
//	/* area */
//	EI_S32 s32Area;
//
//	EI_U64 u64Timestamp;
//} EI_MADP_SMART_MD_RESULT_S;
//
//typedef struct eiMADP_SMART_MD_RESULTS_S {
//	EI_U32 s32Num;
//	EI_MADP_SMART_MD_RESULT_S stObjs[DEFAULT_NNA_MD_CONFIG_MAX_BOX_NUM];
//	EI_U32 u32FrameWidth;
//	EI_U32 u32FrameHeight;
//
//	//for nna
//	EI_U32 NnaHandle;
//	EI_NNA_MOTIONS_S stNnaResult;
//} EI_MADP_SMART_MD_RESULTS_S;
//
//typedef EI_S32 (*PFN_Smart_MD_DataCB) (EI_HANDLE hMbgsDet, EI_MADP_SMART_FRAME_S *pstSmartFrame,
//	EI_MADP_SMART_MD_RESULTS_S *pstDetResults, EI_VOID *pPrivData);
//
///* the attribute of smart mbgs det */
//typedef struct eiMADP_SMART_MD_ATTR_S {
//
//	EI_U32 u32FrameWidth;
//	EI_U32 u32FrameHeight;
//
//	PFN_Smart_MD_DataCB pfnDataCB;
//	EI_VOID *pPrivateData;
//} EI_MADP_SMART_MD_ATTR_S;
//#endif

#define SMART_MD_RECT_MAX 8
#define SMART_MD_STRIDE_SIZE 8



/** motion detect type*/
typedef enum eiMADP_SMART_MD_TYPE_E {
	SMART_MD_DISABLE = 0,	// disable
	SMART_MD_REGION,		// rect region
	SMART_MD_MACRO_BLOCK,	// macro block
	SMART_MBGS_MD_MAX
} EI_MADP_SMART_MD_TYPE_E;


typedef struct eiMADP_SMART_MD_RESULT_S {
	EI_S32 s32ObjRect[4]; // objs rect
	EI_S32 s32Area;
	EI_U64 u64Timestamp;
} EI_MADP_SMART_MD_RESULT_S;

typedef struct eiMADP_SMART_MD_RECT_S {
	EI_S32 s32Rect[4];
	EI_FLOAT fAreaRatio;
} EI_MADP_SMART_MD_RECT_S;

typedef struct eiMADP_SMART_MBGS_MD_MACRO_BLOCK_S {
	EI_U8 u8MdMacroBlock[SMART_MD_STRIDE_SIZE];
	EI_FLOAT fAreaRatio;
} EI_MADP_SMART_MD_MACRO_BLOCK_S;


typedef struct eiMADP_SMART_MD_RECT_RESULT_S {
	EI_MADP_SMART_MD_RECT_S stMdRect;
	EI_U32 u32ObjNum;
	EI_MADP_SMART_MD_RESULT_S stObjs[DEFAULT_NNA_MD_CONFIG_MAX_BOX_NUM];
} EI_MADP_SMART_MD_RECT_RESULT_S;


typedef struct eiMADP_SMART_MD_REGION_RESULT_S {
	EI_S32 s32MdRectNum;
	EI_MADP_SMART_MD_RECT_RESULT_S stMdRectResult[SMART_MD_RECT_MAX];
} EI_MADP_SMART_MD_REGION_RESULT_S;

typedef struct eiMADP_SMART_MD_MACRO_BLOCK_RESULT_S {
	EI_MADP_SMART_MD_MACRO_BLOCK_S mdMacroBlock;
	EI_U32 u32ObjNum;
	EI_MADP_SMART_MD_RESULT_S stObjs[DEFAULT_NNA_MD_CONFIG_MAX_BOX_NUM];
} EI_MADP_SMART_MD_MACRO_BLOCK_RESULT_S;


typedef struct eiMADP_SMART_MD_RESULTS_S {
	EI_U32 u32ObjNum;
	EI_U32 u32FrameWidth;
	EI_U32 u32FrameHeight;
	EI_S32 s32FrameId;
	EI_MADP_SMART_MD_TYPE_E enMdType;
	EI_MADP_SMART_MD_REGION_RESULT_S stMdRgnResult;
	EI_MADP_SMART_MD_MACRO_BLOCK_RESULT_S stMdMbResult;

	//for nna
	EI_U32 NnaHandle;
	EI_NNA_MOTIONS_S stNnaResult;
} EI_MADP_SMART_MD_RESULTS_S;


typedef struct eiMADP_SMART_MD_VENC_DATA_S {
	EI_VOID *pVStreamData;
	EI_U8 *pu8Addr;
	EI_U32 au32Len;
} EI_MADP_SMART_MD_VENC_DATA_S;

typedef struct eiMADP_SMART_MD_CAP_RESULTS_S {
	EI_MADP_SMART_MD_RESULTS_S *pstMdResult;
	// cap frame image
	EI_MADP_SMART_FRAME_S *pstSmartFrame;
} EI_MADP_SMART_MD_CAP_RESULTS_S;

typedef struct eiMADP_SMART_MD_VENC_RESULT_S {
	EI_MADP_SMART_MD_CAP_RESULTS_S *pstSmartCapResults;

	EI_S32 s32FrameId;
	EI_U64 u64Timestamp;
} EI_MADP_SMART_MD_VENC_RESULT_S;

typedef struct eiMADP_SMART_MD_SNAP_RESULT_S {
	EI_MADP_SMART_MD_VENC_RESULT_S *pstMdVencResultData;
	EI_MADP_SMART_MD_VENC_DATA_S *pstBgVencData;
} EI_MADP_SMART_MD_SNAP_RESULT_S;

typedef struct eiMADP_SMART_MD_REGION_S {
	EI_S32 s32MdRectNum;
	EI_MADP_SMART_MD_RECT_S stMdRects[SMART_MD_RECT_MAX];
} EI_MADP_SMART_MD_REGION_S;


typedef EI_S32 (*EI_MADP_SMART_MD_DATA_CB)
	(EI_HANDLE hMbgsCap, EI_MADP_SMART_FRAME_S *pstSmartFrame,
	EI_MADP_SMART_MD_RESULTS_S *pstDetResults, EI_VOID *pPrivData);

typedef EI_S32 (*EI_MADP_SMART_MBGS_SnapDataCB)(EI_HANDLE hCap,
	EI_MADP_SMART_MD_SNAP_RESULT_S *pstSmartMdSnapResults, EI_VOID *pPrivData);


/** the attribute of smart motion det*/
typedef struct eiMADP_SMART_MD_CFG_S {
	EI_BOOL bMdEnable;
	EI_BOOL bMdDrawBoxEnable;
	EI_BOOL bMdDumpBgEnable;
	EI_S32 s32CapMode;
	EI_S32 s32CapInterval;
	EI_S32 s32CapJpegQuality;
	EI_U32 u32FrameWidth;
	EI_U32 u32FrameHeight;
	EI_S32 s32Sensitive;
	EI_MADP_SMART_MD_TYPE_E enMdType;
	EI_MADP_SMART_MD_REGION_S stMdRegion;
	EI_MADP_SMART_MD_MACRO_BLOCK_S stMdMacroBlock;
	EI_MADP_SMART_MD_DATA_CB pfnDataCB;
	EI_MADP_SMART_MBGS_SnapDataCB pfnCapDataCB;
	EI_VOID *pPrivateData;
} EI_MADP_SMART_MD_CFG_S;


/** the attribute of smart mbgs cap*/
typedef struct eiMADP_SMART_MD_ATTR_S {
	/* init attr start*/
	EI_HANDLE Vproc;
	EI_HANDLE Vport;
	EI_HANDLE VencChn;
	EI_HANDLE Det;

	EI_MADP_SMART_MD_CFG_S smartMdCfg;
	EI_NNA_MOTION_CONFIG_S stConfig;
} EI_MADP_SMART_MD_ATTR_S;

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

#endif /* __EI_MAI_SMART_MBGS_H__ */

